package com.demo01.dao.impl;

import com.demo01.dao.User1Dao;
import com.demo01.pojo.User1;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@Repository("user1Dao")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext.xml")
public class User1DaoImpl implements User1Dao {
    @Autowired
    JdbcTemplate jdbcTemplate;

    @Override
    public int insert(User1 user1) {
        int result = jdbcTemplate.update("INSERT INTO `User1` (`name`) VALUES(?)", user1.getName());
        return result;
    }

    @Test
    public void test() {
        System.out.println(insert(new User1(1, "lisi")));
    }
}
